<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

#important includes
include '../includes/config.php';
include '../includes/database.ext.class.php'; 

#create database connection
$database = new Database();
$database->connect('../includes/config.php');

#finish includes
include '../includes/core.ext.class.php';
include '../includes/settings.class.php';
include '../includes/user.class.php';

#vars, classes
$settings = new Settings();
$core = new Core();
$user = new User();
$websiteurl = $settings->getWebsiteURL();

session_start();
if((isset($_POST['uname'])) && (isset($_POST['pwd'])))
{
	$uname = $core->filter($_POST['uname']);
	$pwd = $core->filter($_POST['pwd']);
	if($user->validate($uname, $pwd) == true)
	{
		$salt =  '234204xjla029ax020asoO233';
		$salt2 = 'sDF234kasnl';
		$encpw = sha1($salt . $pwd . $salt2);
		$_SESSION['jcmsuname'] = $uname;
		$_SESSION['jcmspwd'] = $encpw;
	/*	setcookie("jcmsuname", $uname, time()+1800, "/admin/", $websiteurl , 0);
		setcookie("jcmspwd", $encpw, time()+1800, "/admin/", $websiteurl, 0); */
		header("Location: panel");
	}
	else
	{
		header("Location: login?msg=2");
	}
}
else
{
	header("Location: login");
}

?>